package com.qs.entities;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="User")
public class User implements java.io.Serializable {

	private static final long serialVersionUID = 7903887912926919937L;
	
	public User(){
		
	}
	
	public User(String userId){
		this.userId = userId;
	}
		
	@Id
	@Column(name="user_id")
	public String userId;

	@Column(name="first_name")
	public String firstName;
	
	@Column(name="last_name")
	public String lastName;
	
	@Column(name="screen_name")
	public String screenName;
	
	@Column(name="email")
	public String email;

	@Column(name="password")
	public String password;
	
	@Column(name="address")
	public String address;
	
	@Column(name="phone")
	public String phone;
	
	@Column(name="is_login")
	public Boolean isLogin = false;
	
	@Column(name="multi_login_allowed")
	public Boolean multiLoginAllowed = false;
	
	@Column(name="created_on")
	public Timestamp createdOn = new Timestamp((new Date()).getTime());
	
	@Column(name="updated_on",nullable=true)
	public Timestamp updatedOn;
	
	@OneToMany(fetch = FetchType.LAZY)
	public Set<Feed> feeds = new HashSet<Feed>(0);
	
	@OneToMany(fetch = FetchType.LAZY)
	public Set<UserSession> sessions = new HashSet<UserSession>(0);
	
	@OneToMany(fetch = FetchType.LAZY)
	public Set<Rating> ratings = new HashSet<Rating>(0);
	
	@ManyToMany(fetch = FetchType.LAZY,cascade = CascadeType.REFRESH)
	@JoinTable(name = "user_channel", joinColumns = { 
			@JoinColumn(name = "USER_ID", nullable = false, updatable = false) }, 
			inverseJoinColumns = { @JoinColumn(name = "CHANNEL_ID", 
					nullable = false, updatable = false) })
	public Set<Channel> channels;
	

		
}